/*
 * Copyright 2003-2005 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

#ifndef TYPELIBRARY
#define TYPELIBRARY

#ifdef __cplusplus
extern "C" {
#endif


typedef void *(*typeConstructor)( type_list * list, type_map * map );

#define TYPE_BIND_ERROR -3

#define TYPE_OK 0
#define NOTYPE -1

#define TYPE_DEFINED -1
#define TYPE_NOT_COMPLETE -2
#define TYPE_INVALID_STATE -3
#define TYPE_INVALID_PARAM -4
#define TYPE_BAD_NAME -5
#define TYPE_BAD_STATE -6
#define TYPE_NAME_INVALID -7
#define TYPE_NAME_DEFINED -8
#define TYPE_NOT_DEFINED -9

#define TYPE_RESERVED 1
#define TYPE_REGISTERED 2
#define TYPE_COMPLETE 3


struct type_library
{
	int error;
	int count;
	intmap types;
	intmap names; 
};

void type_library_init( type_library * library );
void type_library_destroy( type_library * library );

int type_library_get_error( type_library * library );
void type_library_set_error( type_library * library, int error );

int type_library_get_state( type_library * library, type_name * name );
int type_library_get_id_type_state( type_library * library, int id );

int type_library_register_bind( type_library * library, type_name * name, type_element * structure, typeReader reader, typeWriter writer );
int type_library_register( type_library * library, type_name * name, type_element * structure );
int type_library_reserve( type_library * library, type_name * name );
int type_library_bind( type_library * library, type_name * name, typeReader reader, typeWriter writer );
int type_library_get_id( type_library * library, type_name * name );
type_name * type_library_get_name( type_library * library, int id );
type_element * type_library_get_structure( type_library * library, int id );
typeReader type_library_get_reader( type_library * library, int id );
typeWriter type_library_get_writer( type_library * library, int id );

type_definition * type_library_get_definition( type_library * library, type_name * name );
type_definition * type_library_get_definition_id( type_library * library, int id );

#ifdef __cplusplus
}
#endif

#endif
